#ifndef BOOK_CPP
#define BOOK_CPP
#include "Book.h"

Book::Book(std::string author_, std::string title_, std::string publisher_, int year_, int edition_, std::string ISBN_, int borrowableAmount_) : author(author_), title(title_), publisher(publisher_), year(year_), edition(edition_), ISBN(ISBN_), borrowableAmount(borrowableAmount_)
{
	for (const auto &e : author)
	{
		if (isupper(e))
			id += e;
	}

	for (const auto &e : title)
	{
		if (isupper(e))
			id += e;
	}

	std::ostringstream sstr;
	sstr << year;
	id += sstr.str();

	sstr.str("");
	sstr << edition;
	id += sstr.str();
}

void Book::RemoveBorrower(Member *member)
{
	bool found = false;
	for (auto it = borrowedBy.begin(); it != borrowedBy.end() && !found;)
	{
		if ((*it) == member)
		{
			it = borrowedBy.erase(it);
			found = true;
		}
		else 
			++it;
	}
}

#endif